/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package app.model_package;

import java.util.ArrayList;

/**
 *
 * @author haythem
 */
public class Place {

    private String id_place;
    private ArrayList<String> from ;
    private ArrayList<String> to ;
    // a place is "initial", "intermediary" or "final"
    private String typePlace;

    public Place() {
        from = new ArrayList<String>();
        to = new ArrayList<String>();
    }



    public Place(String id_place, String typePlace){
        this.typePlace = typePlace;
        this.id_place = id_place;
        from = new ArrayList<String>();
        to = new ArrayList<String>();
    }



    /////////////////////////////////////////////////////////////////////

    public String getTypePlace() {
        return typePlace;
    }

    public void setTypePlace(String typePlace) {
        this.typePlace = typePlace;
    }

    public String getId_place() {
        return id_place;
    }

    public void setId_place(String id_place) {
        this.id_place = id_place;
    }

    public ArrayList<String> getFrom() {
        return from;
    }

    public void setFrom(ArrayList<String> from) {
        this.from = from;
    }

    public ArrayList<String> getTo() {
        return to;
    }

    public void setTo(ArrayList<String> to) {
        this.to = to;
    }


    public void addAFrom(String from){
        this.from.add(from);
    }

    public void addATo(String to){
        this.to.add(to);
    }


    /////////////////////////////////////////////////////////////////////

    /**
     * to write the Place using the form
     * for exemple P{C},{D,E}
     * @return
     */
    @Override
    public String toString(){
        String s="";
        if ((!this.typePlace.equals((String) "initial")) && (!this.typePlace.equals((String) "final"))){
            s += "P{";
            for (int i=0;i<((this.from.size())-1);i++){
                s+= this.from.get(i)+", ";
            }
            s+= this.from.get((this.from.size())-1)+"},{";

            for (int i=0;i<((this.to.size())-1);i++){
                s+= this.to.get(i)+", ";
            }
            s+= this.to.get((this.to.size())-1)+"} -> place ID : "+this.id_place;
//            System.out.println(s);
        }
        
        return s;
    }



}
